package cn.getech.data.development.controller.datasyn;

/**
 * @description: 数据常用静态sql语句
 * @author: wangzhaowen：kiss
 * @create: 2021/3/25 18:52
 * @version: 2021/3/25
 **/
public class DbSql {

    public static String MYSQL_COLUMN_SQL="select column_name as column_name ,data_type as data_type , " +
            "column_comment as comments, column_type AS data_length  " +
            " from information_schema.columns where table_schema= '%s' and  table_name= '%s'  ";
    public static String ORACLE_COLUMN_SQL="select  t.column_name as column_name,  t.data_type as data_type,  " +
            "( select c.comments  from all_col_comments c where c.owner=t.owner  and c.table_name=t.table_name " +
            " and c.column_name=t.column_name  and rownum=1) as comments  " +
            "from all_tab_columns t where t.table_name='%s' and  t.owner = '%s' ";
    public static String ORACLE_COLUMN_LENGTH_SQL ="select column_name as column_name ,data_type as data_type ," +
            "data_length as data_length  from  all_tab_columns where table_name = '%s' and  owner = '%s' ";


    public static String MYSQL_TABLE_COMMENT_SQL="select table_comment as table_comment from information_schema.tables " +
            "where table_schema='%s' and table_name='%s' ";

    public static String ORACLE_TABLE_COMMENT_SQL="select comments as table_comment from user_tab_comments " +
            "where table_name= '%s' ";



    public static String ORACLE_TABLES_SQL = "select  t.table_name as table_name , t.comments as comments  f" +
            "rom all_tab_comments t " +
            "where   t.table_name NOT LIKE '%$%' and  t.owner = '#{userName}' ";

    public static String MYSQL_TABLES_SQL = "select t.table_name as table_name ,t.table_comment as comments  " +
            "from information_schema.tables t where  t.table_schema ='%s' ";



    public static String MYSQL_TABLES_PRIMARYKEY_SQL = "select t.column_name  as column_name " +
            "from information_schema.key_column_usage t where t.table_schema = '%s' AND table_name =  '%s' ";

    public static String ORACLE_TABLES_PRIMARYKEY_SQL = "select t.constraint_name  from dba_constraints t " +
            "where t .constraint_type='P' and t.table_name= '%s'";
}
